#pragma once
#include "WareTypes.h"
#include "WarePrepare.h"
#include "WareAssert.h"
#include "GraphicDef.h"
#include "ITexture.h"
#include "IResource.h"
#include "WareEngineNameSpace.h"

BEGIN_WARE

class CTextureManager;

class CTexture : public IResource, public ITexture
{
public:
	friend class CTextureManager;

	CTexture(void);
	virtual ~CTexture(void);

	virtual int32		GetWidth()	{ return m_nWidth; };
	virtual int32		GetHeight()	{ return m_nHeight; };

	virtual EWareFormat GetFormat()	{ return m_eFormat; }

	virtual int32		GetID()		{ return m_uID; };

	virtual int32		Grab();
	virtual int32		Drop();

protected:
	void				SetID( uint32 uID )								{ m_uID = uID; }

	void				SetResourceName( const VCHAR* szFileName )		{ m_strFileName = szFileName; }

	void				SetManager( CTextureManager* pTextureManager )	{ m_pTextureManager = pTextureManager; }

	void				SetFormat( EWareFormat eFormat )				{ m_eFormat = eFormat; } 
	/// 
	void				SetForceFilter( VBOOL bForceFilter )			{ m_bForceFilter = bForceFilter; }

	void				SetMipmapLevel( int32 nMipmapLevel )			{ m_nMipmapLevel = nMipmapLevel; }

protected:
	string				m_strFileName;

	BYTE*				m_pBuff;
	uint32				m_uLenght;

	int32				m_nWidth;
	int32				m_nHeight;
	EWareFormat			m_eFormat;
	VBOOL				m_bForceFilter;
	int32				m_nMipmapLevel;

private:
	uint32				m_uID;
	CTextureManager*	m_pTextureManager;
};

END_WARE